package com.enation.app.shop.front.policyInsurance.service.impl;

import com.enation.app.shop.front.policyInsurance.entity.InsuranceTemplate;
import com.enation.app.shop.front.policyInsurance.service.IinsuranceTemplateManager;
import com.enation.framework.database.IDaoSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("insuranceTemplateService")
public class InsuranceTemplateManager implements IinsuranceTemplateManager {
    @Autowired
    private IDaoSupport daoSupport;
    @Override
    public List<InsuranceTemplate> getByCompanyId(Integer companyid) {
        String  sql="select * from rbt_insurance_template where company_id=?";
        return daoSupport.queryForList(sql,InsuranceTemplate.class,companyid);
    }

    @Override
    public int create(InsuranceTemplate insuranceTemplate) {
        daoSupport.insert("rbt_insurance_template",insuranceTemplate);
        Integer id = this.daoSupport.getLastId("rbt_insurance_template");
        return id;
    }

    @Override
    public int update(InsuranceTemplate insuranceTemplate) {
        String sql = "UPDATE rbt_insurance_company " +
                "r set r.company_name='?'," +
                "r.tel='?', " +
                "r.detail='?'," +
                "r.logo='?'," +
                "r.status=? where id=?";
        return 0;
    }

    @Override
    public int delete(Integer id) {
        return 0;
    }

    @Override
    public InsuranceTemplate getById(Integer id) {
        return null;
    }

    @Override
    public List<InsuranceTemplate> getAll() {
        String  sql="select * from rbt_insurance_template ";
        return daoSupport.queryForList(sql,InsuranceTemplate.class);
    }
}
